﻿#define _CRT_SECURE_NO_WARNINGS//递归和非递归分别实现求第n个斐波那契数
#include<stdio.h>
fib1(int n)
{
	int a = 1, c = 1, b = 1, i = 1;
	if (n <= 2)
		return 1;
	else while (i <= n - 2)
	{
		c = a + b;
		a = b;
		b = c;
		i++;
	}
	return c;
}
fib2(int n)
{

	if (n <= 2)
		return 1;
	else
		return fib2(n - 1) + fib2(n - 2);

}
int main()
{
	int n = 0;
	scanf("%d", &n);
	int x = fib1(n);
	printf("非递归：%d\n", x);
	int y = fib2(n);
	printf("递归：%d\n", y);
	return 0;
}